package com.aatattoo.light_food_service.service;

import com.aatattoo.light_food_service.entity.*;
import com.aatattoo.light_food_service.mapper.DynamicMapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * @Author aatattoo
 * @Date 2021/12/9 9:27 下午
 * @msg:
 */
@Service
@Component
public class DynamicService {
    @Autowired
    private DynamicMapper dynamicMapper;
    /**
     * 新增动态
     * @param dynamic #{userId}发布动态用户id
     *                #{content}发布动态内容
     *                #{haveImg}该动态是否有图片
     *                #{haveTag}该动态是否有标签
     *                #{haveRemind}该动态是否有@的用户
     *                #{type}动态类型
     * @return 返回新增表单的id
     */
    public int addDynamic(Dynamic dynamic){
        dynamicMapper.addDynamic(dynamic);
        return dynamic.getId();
    }

    public int updataDynamic(Dynamic dynamic){
        return dynamicMapper.updataDynamic(dynamic);
    }

    public Dynamic findById(int id){
        return dynamicMapper.findById(id);
    }

    public int updataType(Dynamic dynamic){
        return dynamicMapper.updataType(dynamic);
    }

    public  int deleteById(int id){
        return dynamicMapper.deleteById(id);
    }

    public List<Dynamic> getDynamicForPublic(){
        return dynamicMapper.getDynamicForPublic();
    }

    public List<Dynamic> getDynamicForPublicByOthUser(int userId){
        return dynamicMapper.getDynamicForPublicByOthUser(userId);
    }

    public List<Dynamic> getDynamicForPublicByUserId(List<Integer> idList){
        return dynamicMapper.getDynamicForPublicByUserId(idList);
    }

    public List<Dynamic> getDynamicForMine(int userId){
        return dynamicMapper.getDynamicForMine(userId);
    }

    public int countDynamicByUserId(int userId){
        return dynamicMapper.countDynamicByUserId(userId);
    }

    public List<Dynamic> fuzzyQuery(String content){
        return dynamicMapper.fuzzyQuery(content);
    }

    public List<Dynamic> getDynamicForTag(@Param("idList")List<Integer> idList){
        return dynamicMapper.getDynamicForTag(idList);
    }

    public List<Integer> getDynamicIdForMine(int userId){
        return dynamicMapper.getDynamicIdForMine(userId);
    }



}
